﻿<UserControl 
    x:Class="FU.Capstones.IMS.Web.Silverlight.Views.EmployeeDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"
    xmlns:telerikInput="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Input"
    xmlns:Controls="clr-namespace:FU.Capstones.IMS.Web.Silverlight.Controls"
    xmlns:Navigation="clr-namespace:Navigation.Silverlight;assembly=Navigation.Silverlight" 
    xmlns:TControls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
    xmlns:Controls1="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView" 
    xmlns:Common="clr-namespace:FU.Capstones.IMS.Web.Common;assembly=FU.Capstones.IMS.Web.Common" 
    xmlns:MultiBindingHelpers="clr-namespace:FU.Capstones.IMS.Web.Common.MultiBindingHelpers;assembly=FU.Capstones.IMS.Web.Common" 
    Navigation:ViewModel.TypeName="FU.Capstones.IMS.Web.Silverlight.ViewModels.EmployeeDetailViewModel"
    >

    <UserControl.Resources>
        <Common:DataContextProxy x:Key="DataContextProxy"/>
    </UserControl.Resources>

    <telerik:RadBusyIndicator
        BusyContent="Đang kết nối tới máy chủ..."
        IsBusy="{Binding Path=ServiceCallCounter, Converter={StaticResource IntegerToBoolConverter}}"
        >
        <Grid x:Name="LayoutRoot" Style="{StaticResource ViewGridStyle}">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="10"/>
            </Grid.RowDefinitions>
            <!--Title-->
            <Grid Grid.ColumnSpan="3">                
                <Grid.Background>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop0}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop1}"/>
                        <GradientStop Color="{StaticResource InnerColor}" Offset="{StaticResource ControlBackgroundGradientStop2}"/>
                        <GradientStop Color="{StaticResource OuterColor}" Offset="{StaticResource ControlBackgroundGradientStop3}"/>
                    </LinearGradientBrush>
                </Grid.Background>
                
                <TextBlock 
                    x:Name="lblTitle" 
                    Style="{StaticResource TextBlockTitlePageStyle}"                   
                    Text="Thông tin nhân viên"/>
            </Grid>
            <TControls:RadTabControl                
                Grid.Row="2"  Grid.Column="0" Grid.ColumnSpan="3"
                Background="Transparent"
                >
                <TControls:RadTabItem
                    Header="Thông tin chung"
                    Background="Transparent"
                    >
                    <!--Input data field-->
                    <Grid x:Name="InputField">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <!--Username-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="0"
                            >
                            <Run Text="{StaticResource UsernameLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <TextBox 
                            x:Name="txtUserName" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="0"
                            IsEnabled="{Binding Path=IsCreateNew, Mode=OneWay}"
                            Text="{Binding Path=Employee.Username, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <telerik:RadButton 
                            Grid.Column="3" Grid.Row="0"
                            Command="{Binding Path=ResetPasswordCommand}" 
                            Content="{StaticResource ResetPwdButtonText}" 
                            Style="{StaticResource TRadButtonNormalStyle}" 
                            telerik:StyleManager.Theme="Office_Black" 
                            >
                            <MultiBindingHelpers:BindingUtil.MultiBindings >
                                <MultiBindingHelpers:MultiBindings>
                                    <MultiBindingHelpers:MultiBinding TargetProperty="Visibility" Converter="{StaticResource MultiBoolsToVisibilityConverter}" >
                                        <MultiBindingHelpers:MultiBinding.Bindings>
                                            <MultiBindingHelpers:BindingCollection>
                                                <Binding Path="CanEditOrAdd"/>
                                                <Binding Path="IsCreateNew"/>
                                            </MultiBindingHelpers:BindingCollection>
                                        </MultiBindingHelpers:MultiBinding.Bindings>
                                    </MultiBindingHelpers:MultiBinding>
                                </MultiBindingHelpers:MultiBindings>
                            </MultiBindingHelpers:BindingUtil.MultiBindings>
                        </telerik:RadButton>

                        <!--Name-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="1">
                            <Run Text="{StaticResource EmployeeLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <TextBox 
                            x:Name="txtEmployeeName"
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="1"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.FullName, Mode=Twoway, ValidatesOnDataErrors=True}"
                    
                            />

                        <!--BirthDate-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="2">
                            <Run Text="{StaticResource DateOfBirthLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <telerikInput:RadDatePicker 
                            x:Name="txtBirthdate"
                            Grid.Column="2" Grid.Row="2"
                            Style="{StaticResource TelerikDatePickerNormalStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            SelectedDate="{Binding Path=Employee.DateOfBirth, Mode=TwoWay, ValidatesOnDataErrors=True}"                    
                            />

                        <!--Gender-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}" 
                            Grid.Column="1" Grid.Row="3">
                            <Run Text="{StaticResource GenderLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <ComboBox
                            Grid.Column="2" Grid.Row="3"
                            Style="{StaticResource ComboBoxNormalStyle}"
                            ItemsSource="{Binding Path=GenderCollection}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            SelectedItem="{Binding Path=Employee.Gender, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <!--So CMND-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="4">
                            <Run Text="{StaticResource IdentityCardNumberLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <TextBox 
                            x:Name="txtIdentityCardNumber" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="4"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.IdentityCardNumber, Mode=TwoWay, ValidatesOnDataErrors=True}"
                            />

                        <!--Address-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}" 
                            Grid.Column="1" Grid.Row="5">
                            <Run Text="{StaticResource AddressLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <TextBox
                            x:Name="txtAddress" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="5"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.Address, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <!--Role-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}" 
                            Grid.Column="1" Grid.Row="6" >
                            <Run Text="{StaticResource RoleLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <ComboBox 
                            x:Name="cbRole" 
                            Style="{StaticResource ComboBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="6"
                            ItemsSource="{Binding Path=RoleCollection, Mode=OneWay}"
                            DisplayMemberPath="RoleName"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            SelectedItem="{Binding Path=Employee.Role, Mode=TwoWay, ValidatesOnDataErrors=True}"
                            >
                            <!--<i:Interaction.Triggers>
                                <i:EventTrigger EventName="SelectionChanged">
                                    <i:InvokeCommandAction Command="{Binding Path=SelectRoleCommand}"/>
                                </i:EventTrigger>
                            </i:Interaction.Triggers>-->
                        </ComboBox>

                        <!--EmploymentType-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}" 
                            Grid.Column="1" Grid.Row="7" >
                            <Run Text="{StaticResource EmploymentTypeLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <ComboBox 
                            x:Name="cbEmploymentType" 
                            Style="{StaticResource ComboBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="7"
                            ItemsSource="{Binding Path=EmploymentTypeCollection, Mode=OneWay}"
                            DisplayMemberPath="EmploymentTypeName"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            SelectedItem="{Binding Path=Employee.EmploymentType, Mode=TwoWay, ValidatesOnDataErrors=True}"                        
                        />

                        <!--JoinedDate-->
                        <TextBlock
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="8">
                            <Run Text="{StaticResource JoinedDateLabelText}" />
                            <Run Foreground="Red" Text="*" />
                        </TextBlock>

                        <telerikInput:RadDatePicker 
                            x:Name="txtJoinedDate" 
                            Grid.Column="2" Grid.Row="8"
                            Style="{StaticResource TelerikDatePickerNormalStyle}"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            SelectedDate="{Binding Path=Employee.JoinedDate, Mode=TwoWay, ValidatesOnDataErrors=True}"
                            />

                        <!--Email-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}" 
                            Grid.Column="1" Grid.Row="9"
                            Text="{StaticResource EmailLabelText}" />

                        <TextBox 
                            x:Name="txtEmail" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="9"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.Email, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <!--Home phone-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="10" 
                            Text="{StaticResource PhoneNumberLabelText}"/>

                        <TextBox 
                            x:Name="txtHomePhone" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="10"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.PhoneNumber, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <!--Mobile-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}" 
                            Grid.Column="1" Grid.Row="11" 
                            Text="{StaticResource MobileNumberLabelText}"/>

                        <TextBox 
                            x:Name="txtMobile" 
                            Style="{StaticResource TextBoxNormalStyle}"
                            Grid.Column="2" Grid.Row="11"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.MobileNumber, Mode=TwoWay, ValidatesOnDataErrors=True}"
                        />

                        <!--Comment-->
                        <TextBlock 
                            Style="{StaticResource TextBlockNormalStyle}"
                            Grid.Column="1" Grid.Row="12"
                            Text ="{StaticResource BriefDescriptionLabelText}"/>

                        <TextBox 
                            x:Name="txtComment" 
                            Style="{StaticResource TextBoxMultilineStyle}"
                            Grid.Column="2" Grid.Row="12"
                            IsEnabled ="{Binding Path=CanEditOrAdd, Mode=OneWay}" 
                            Text="{Binding Path=Employee.Description, Mode=TwoWay}"
                        />

                    </Grid>

                </TControls:RadTabItem>
                
                <TControls:RadTabItem
                    Header="Tác vụ"
                    Background="Transparent">
                    <Controls1:RadGridView
                        telerik:StyleManager.Theme="Office_Black"
                        Style="{StaticResource RadGridViewNormal}"
                        ItemsSource="{Binding Path=AuthorizationCollection}"
                        >
                        <Controls1:RadGridView.Columns>
                            <Controls1:GridViewColumn
                                Header="Chọn">
                                <Controls1:GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <CheckBox
                                            HorizontalAlignment="Center"
                                            IsChecked="{Binding Path=IsSelected, Mode=TwoWay}"
                                            IsEnabled ="{Binding Path=DataSource.CanEditOrAdd, Mode=OneWay, Source={StaticResource DataContextProxy}}" 
                                            Command="{Binding Path=DataSource.SelectCommand, Source={StaticResource DataContextProxy}}"
                                            CommandParameter="{Binding Path=AuthorizationID}"
                                        />
                                    </DataTemplate>
                                </Controls1:GridViewColumn.CellTemplate>
                            </Controls1:GridViewColumn>
                            <Controls1:GridViewDataColumn 
                                Header="Tác vụ" 
                                DataMemberBinding="{Binding Path=Description}"
                                />
                        </Controls1:RadGridView.Columns>
                    </Controls1:RadGridView>
                </TControls:RadTabItem>
                
            </TControls:RadTabControl>
            
            <TextBlock
                Grid.Row="4" Grid.Column="0" HorizontalAlignment="Center" Grid.ColumnSpan="3"
                Style="{StaticResource ErrorMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=ErrorMessageVisibility, Mode=TwoWay}"
            />

            <TextBlock
                Grid.Row="4" Grid.Column="0" HorizontalAlignment="Center" Grid.ColumnSpan="3"
                Style="{StaticResource SuccessfulMessageTextBlockStyle}"
                Text="{Binding Path=Message, Mode=TwoWay}"
                Visibility="{Binding Path=MessageVisibility, Mode=TwoWay}"
            />
            
            <StackPanel
                Orientation="Horizontal" HorizontalAlignment="Center"
                Grid.Column="0" Grid.Row="5" Grid.ColumnSpan="3">
                <!--Buttons-->
                <Controls:SaveButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:ResetButtonControl 
                    Visibility ="{Binding Path=CanEditOrAdd, Mode=OneWay, Converter={StaticResource BoolToVisibilityConverter}}"
                    />

                <Controls:BackButtonControl
                    />
            </StackPanel>          
        </Grid>
    </telerik:RadBusyIndicator>
</UserControl>
